package l2ft.gameserver.model.items;

import l2ft.gameserver.model.instances.FakePcInstance;
import l2ft.gameserver.stats.funcs.Func;
import l2ft.gameserver.templates.item.ItemTemplate;

public class FakePcInventory extends ItemContainer
{

	public static final int PAPERDOLL_UNDER = 0;
	public static final int PAPERDOLL_REAR = 1;
	public static final int PAPERDOLL_LEAR = 2;
	public static final int PAPERDOLL_NECK = 3;
	public static final int PAPERDOLL_RFINGER = 4;
	public static final int PAPERDOLL_LFINGER = 5;
	public static final int PAPERDOLL_HEAD = 6;
	public static final int PAPERDOLL_RHAND = 7;
	public static final int PAPERDOLL_LHAND = 8;
	public static final int PAPERDOLL_GLOVES = 9;
	public static final int PAPERDOLL_CHEST = 10;
	public static final int PAPERDOLL_LEGS = 11;
	public static final int PAPERDOLL_FEET = 12;
	public static final int PAPERDOLL_BACK = 13;
	public static final int PAPERDOLL_LRHAND = 14;
	public static final int PAPERDOLL_HAIR = 15;
	public static final int PAPERDOLL_DHAIR = 16;
	public static final int PAPERDOLL_RBRACELET = 17;
	public static final int PAPERDOLL_LBRACELET = 18;
	public static final int PAPERDOLL_DECO1 = 19;
	public static final int PAPERDOLL_DECO2 = 20;
	public static final int PAPERDOLL_DECO3 = 21;
	public static final int PAPERDOLL_DECO4 = 22;
	public static final int PAPERDOLL_DECO5 = 23;
	public static final int PAPERDOLL_DECO6 = 24;
	public static final int PAPERDOLL_BELT = 25;
	
	public final FakePcInstance _owner;
	protected final ItemInstance[] _paperdoll = new ItemInstance[25];
	
	public FakePcInventory(FakePcInstance npc)
	{
		_owner = npc;
	}
	
	@Override
	protected void onAddItem(ItemInstance item) 
	{
		addToSlot(item);
		Func[] funcs = item.getStatFuncs();
		_owner.addStatFuncs(funcs);
		_owner.updateStats();
	}

	private void addToSlot(ItemInstance item)
	{
		switch(item.getBodyPart())
		{
		case ItemTemplate.SLOT_LR_HAND:
			_paperdoll[PAPERDOLL_RHAND] = item;
			_paperdoll[PAPERDOLL_LHAND] = item;
			break;
		case ItemTemplate.SLOT_L_HAND:
			_paperdoll[PAPERDOLL_LHAND] = item;
			break;
		case ItemTemplate.SLOT_R_HAND:
			_paperdoll[PAPERDOLL_RHAND] = item;
			break;
		case ItemTemplate.SLOT_L_EAR:
		case ItemTemplate.SLOT_R_EAR:
			if(_paperdoll[PAPERDOLL_LEAR] == null)
				_paperdoll[PAPERDOLL_LEAR] = item;
			else
				_paperdoll[PAPERDOLL_REAR] = item;
			break;
		case ItemTemplate.SLOT_L_FINGER:
		case ItemTemplate.SLOT_R_FINGER:
			if(_paperdoll[PAPERDOLL_LFINGER] == null)
				_paperdoll[PAPERDOLL_LFINGER] = item;
			else
				_paperdoll[PAPERDOLL_RFINGER] = item;
			break;
		case ItemTemplate.SLOT_NECK:
			_paperdoll[PAPERDOLL_NECK] = item;
			break;
		case ItemTemplate.SLOT_FULL_ARMOR:
			_paperdoll[PAPERDOLL_LEGS] = item;
			_paperdoll[PAPERDOLL_CHEST] = item;
			break;
		case ItemTemplate.SLOT_CHEST:
			_paperdoll[PAPERDOLL_CHEST] = item;
			break;
		case ItemTemplate.SLOT_LEGS:
			_paperdoll[PAPERDOLL_LEGS] = item;
			break;
		case ItemTemplate.SLOT_FEET:
			_paperdoll[PAPERDOLL_FEET] = item;
			break;
		case ItemTemplate.SLOT_GLOVES:
			_paperdoll[PAPERDOLL_GLOVES] = item;
			break;
		case ItemTemplate.SLOT_HEAD:
			_paperdoll[PAPERDOLL_HEAD] = item;
			break;
		}
	}


	public ItemInstance getItemInSlot(int slot)
	{
		return _paperdoll[slot];
	}
	
	@Override
	protected void onModifyItem(ItemInstance item) {
		
	}

	@Override
	protected void onRemoveItem(ItemInstance item) {
	}

	@Override
	protected void onDestroyItem(ItemInstance item) {
		
	}

}